﻿using System;
using System.Web.UI.WebControls;
using ZHDJ.Data.Models.JoinParty;
using ZHDJ.JoinParty.BLL;

namespace ZHDJ.PersonalCenter.Module.OrganizationalLife
{
    public partial class MyApplyJoinParty : BLL.PageBase
    {
        #region 属性
        private string AppllicationID { get; set; }
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                GetAppllicationID();
                if (!string.IsNullOrWhiteSpace(this.AppllicationID))
                {
                    this.LoadData();
                }
                else
                {
                    string okScript = "window.open('../../../../Portal/JoinPartyNotice.aspx');";
                    FineUI.Confirm.Show("您没有发起入党申请，无法查看！是否跳转到入党界面？", "提示", okScript, "");
                }
            }
        }

        #region 数据访问
        /// <summary>
        /// 获取当前用户的申请id
        /// </summary>
        private void GetAppllicationID()
        {
            AppllicationID = PartyJoinApplycation.GetApplyIDNoParamByLoginID(this.CurrentUser.LoginID);
        }

        /// <summary>
        /// LoadData
        /// </summary>
        protected void LoadData()
        {
            ZHDJ.Core.Log.Log4netHelper.WriteLog(this.AppllicationID);
            this.rpFlow.DataSource = PartyJoinLinkExample.GetGridData(this.AppllicationID);
            this.rpFlow.DataBind();
            link8.NavigateUrl = "../../../JoinParty/Template/TJoinStep08.aspx?AppllicationID=" + this.AppllicationID;
            link9.NavigateUrl = "../../../JoinParty/Template/TJoinStep09.aspx?AppllicationID=" + this.AppllicationID;
            link15.NavigateUrl = "../../../JoinParty/Template/TJoinStep15All.aspx?AppllicationID=" + this.AppllicationID;
            link19.NavigateUrl = "../../../JoinParty/Template/TJoinStep19.aspx?AppllicationID=" + this.AppllicationID;
            link25.NavigateUrl = "../../../JoinParty/Template/TJoinStep25.aspx?AppllicationID=" + this.AppllicationID;
            link31.NavigateUrl = "../../../JoinParty/Template/TJoinStep31.aspx?AppllicationID=" + this.AppllicationID;
            link35.NavigateUrl = "../../../JoinParty/Template/TJoinStep35.aspx?AppllicationID=" + this.AppllicationID;
        }

        /// <summary>
        /// 通过流程状态值获取状态名称
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        public static string GetStatusName(string status)
        {
            string retStr = string.Empty;
            string retStrEx = string.Empty;

            int intStatus = 0;
            try
            {
                if (!string.IsNullOrEmpty(status))
                {
                    intStatus = Convert.ToInt16(status);
                    retStr = Enum.GetName(typeof(Enum_FlowStanceStatus), intStatus);
                    if (retStr == "未处理")
                    {
                        retStrEx = "<a style='color:red'>" + retStr + "</a>";
                    }
                    else retStrEx = retStr;
                }
            }
            catch (Exception ex)
            {
                retStr = "";
            }
            return retStrEx;
        }
        #endregion
    }
}